<?php
namespace app\api\controller;
use \app\index\model as indexModel;
use \app\api\model as apiModel;
class Index
{
    public function getNews($col = null,$p = 0,$limit = 10){
        // $col = input("get.col") || $col;
        // $p = input("get.p") || $p;
        // $limit = input("get.limit") || $limit;

        if(empty($col)){
            return ["code"=>0,"msg"=>"栏目不存在"];
        }
        $m = new apiModel\EcmsNews();
        $res = $m->getNewsList($p,$col,$limit,",smalltext,titlepic,ispic,ftitle");

        if(empty($res)){
            return ["code"=>0,"msg"=>"没有更多的数据"];
        }
        foreach ($res as $key => $value) {
            $res[$key]['title'] = stripslashes($value['title']);
            $res[$key]['smalltext'] = str_convert($value['smalltext']);
            $res[$key]['titleurl'] = url("index/index/art",['id'=>$value['id']]);
        }
        return $res;
    }

    public function getGoods(){

        $limit = input("get.limit",5);

        $m = new apiModel\EcmsNews();
        $res = $m->getGoodList($limit);

        if(empty($res)){
            return ["code"=>0,"msg"=>"没有更多的数据"];
        }
        return $res;

    }
}
